package cn.lj.config;

import cn.lj.interceptor.LoginInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author lj
 * @Description: 拦截器配置类
 * @date 2020-11-26 22:24
 * @QQ 851477108
 */


public class WebConfig implements WebMvcConfigurer {
    /**
     * 配置拦截器,拦截admin路径下除了本身和login的外所有路径
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                //注册拦截器registry.addInterceptor,设置拦截进来的路径addPathPatterns
                .addPathPatterns("/admin/**")
                //拦截忽视本身路径和登录路径excludePathPatterns
                .excludePathPatterns("/admin")
                .excludePathPatterns("/admin/login");
    }
}
